<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>用户注册</title>
	<script src="js/ajaxGO.js"></script>
	<script src="js/jq.js"></script>
	<style>
		* {
			margin: 0;
			padding: 0;
		}

		a {
			text-decoration: none;
		}

		input,
		button {
			background: transparent;
			border: 0;
			outline: none;
		}

		body {
			height: 100vh;
			background: linear-gradient(#141e30, #243b55);
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 16px;
			color: #03e9f4;
		}

		.loginBox {
			width: 400px;
			height: 550px;
			background-color: #0c1622;
			margin: 100px auto;
			border-radius: 10px;
			box-shadow: 0 15px 25px 0 rgba(0, 0, 0, .6);
			padding: 40px;
			box-sizing: border-box;
		}

		h2 {
			text-align: center;
			color: aliceblue;
			margin-bottom: 30px;
			font-family: 'Courier New', Courier, monospace;
		}

		.item {
			height: 45px;
			border-bottom: 1px solid #fff;
			margin-bottom: 40px;
			position: relative;
		}

		.item input {
			width: 100%;
			height: 100%;
			color: #fff;
			padding-top: 20px;
			box-sizing: border-box;
		}

		.item input:focus+label,
		.item input:valid+label {
			top: 0px;
			font-size: 2px;
		}

		.item label {
			position: absolute;
			left: 0;
			top: 12px;
			transition: all 0.5s linear;
		}

		.btn {
			padding: 10px 20px;
			margin-top: 30px;
			color: #03e9f4;
			position: relative;
			overflow: hidden;
			text-transform: uppercase;
			letter-spacing: 2px;
			left: 35%;
		}

		.btn:hover {
			border-radius: 5px;
			color: #fff;
			background: #03e9f4;
			box-shadow: 0 0 5px 0 #03e9f4,
			0 0 25px 0 #03e9f4,
			0 0 50px 0 #03e9f4,
			0 0 100px 0 #03e9f4;
			transition: all 1s linear;
		}

		.btn>span {
			position: absolute;
		}

		.btn>span:nth-child(1) {
			width: 100%;
			height: 2px;
			background: -webkit-linear-gradient(left, transparent, #03e9f4);
			left: -100%;
			top: 0px;
			animation: line1 1s linear infinite;
		}

		@keyframes line1 {

			50%,
			100% {
				left: 100%;
			}
		}

		.btn>span:nth-child(2) {
			width: 2px;
			height: 100%;
			background: -webkit-linear-gradient(top, transparent, #03e9f4);
			right: 0px;
			top: -100%;
			animation: line2 1s 0.25s linear infinite;
		}

		@keyframes line2 {

			50%,
			100% {
				top: 100%;
			}
		}

		.btn>span:nth-child(3) {
			width: 100%;
			height: 2px;
			background: -webkit-linear-gradient(left, #03e9f4, transparent);
			left: 100%;
			bottom: 0px;
			animation: line3 1s 0.75s linear infinite;
		}

		@keyframes line3 {

			50%,
			100% {
				left: -100%;
			}
		}

		.btn>span:nth-child(4) {
			width: 2px;
			height: 100%;
			background: -webkit-linear-gradient(top, transparent, #03e9f4);
			left: 0px;
			top: 100%;
			animation: line4 1s 1s linear infinite;
		}

		@keyframes line4 {

			50%,
			100% {
				top: -100%;
			}
		}
	</style>
</head>

<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>


<body>
<div class="loginBox">
	<h2>register</h2>
	<form action="./teacherAddServlet" method="post">
		<!-- 老师名字 -->
		<div class="item">
			<input type="text" autocomplete="off" id="teacherName"  name="teacherName" required>
			<label>teacherName</label>
		</div>
		<!-- 用户名 -->
		<div class="item">
			<input type="text" autocomplete="off" id="userName" name="userName" required>
			<label>userName</label>
		</div>
		<!-- 密码 -->
		<div class="item">
			<input type="password" id="password" name="password" required>
			<label>password</label>
		</div>
		<!-- 确认密码 -->
		<div class="item">
			<input type="password" id="password02" name="password02" required>
			<label>Confirm password</label>
		</div>

		<!-- 注册提交按钮 -->
		<button class="btn" type="submit" style="margin-left: -75px;"  >submit
			<span></span>
			<span></span>
			<span></span>
			<span></span>
		</button>
		<!-- 返回上一页按钮 -->
		<button class="btn" type="button" onclick="javascript:history.go(-1);">back
			<span></span>
			<span></span>
			<span></span>
			<span></span>
		</button>
	</form>



</div>
<script type="text/javascript">

	$("#teacherName").blur(function () {
		if ($("#teacherName").val()==""){
			alert("老师姓名不能为空！");
		}

	})



	$("#userName").blur(function () {
		var yw=/^[A-Za-z]{1}[A-Za-z0-9]*/;
		var aa=$("#userName").val();
		debugger

		if($("#userName").val()==""){
			alert("用户姓名不能为空");
		}else{
			if(yw.test(aa)){
				debugger
				$.ajax({
					type:"post",
					data:{"userName": $("#userName").val()},
					url:"./chachongServlet",
					dataType:"JSON",
					success: function (data,xhr) {

					},//只有当请求完毕哪怕请求失败也会调用的函数
					complete:function (data){
						//得到其json数据

						if(data.status==200 && data.readyState==4){
							ch(JSON.parse(data.responseText))
						}

					},
					error:function (errorMsg){

					}

				})


			}else {
				alert("用户名必须是英文")
			}

		}
	})
	var ch=function (data){

		debugger
		if (data.hang!="0"){
			alert("用户姓名重复");
			$("#userName").val("");

		}

	}


	$("#password").blur(function () {
		if ($("#password").val()==""){
			alert("密码不能为空");
		}

	})

	$("#password02").blur(function () {
				debugger
				if ($("#password").val()!=$("#password02").val()) {
					alert("密码必须相同！请重新输入");
					$("#password02").val("");
				}
			}

	)


























</script>



</body>
</html>
